/**
 * @USER: Administrator
 * @DATE: 2024/9/27 下午11:10
 * @VERSION: 1.0.0
 */
public class LC2965 {
    public static void main(String[] args) {

    }

    public int[] findMissingAndRepeatedValues(int[][] grid) {
        int[] result = new int[2];
        int[] counts = new int[grid.length*grid.length];
        for (int[] ints : grid) {
            for (int anInt : ints) {
                counts[anInt-1]++;
            }
        }

        for (int i = 0; i < counts.length; i++) {
            if (counts[i] == 0) {
                result[1] = i+1;
            } else if (counts[i]==2) {
                result[0] = i+1;
            }
        }

        return result;
    }

}
